-
-
Notifications
You must be signed in to change notification settings - Fork 536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(parser,css_parser): implement checkpoint rewinding #1417
Conversation
✅ Deploy Preview for biomejs canceled.
|
Parser conformance results onjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
p: &mut CssParser, | ||
func: impl FnOnce(&mut CssParser) -> Result<T, E>, | ||
) -> Result<T, E> { | ||
let checkpoint = p.checkpoint(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to implement speculative_parsing
?
It blocks a parse recovery since we're going to rewind anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose it's probably best that we do just for safety. I don't think we need it strictly for how it'll be used here, but definitely no harm in including it. I'll add it in now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉🎉🎉
CodSpeed Performance ReportMerging #1417 will not alter performanceFalling back to comparing Summary
|
273627f
to
433c4dd
Compare
Summary
From #268 (comment), this implements checkpoint rewinding for the CSS parser to set up for attempting to parse property values and then falling back to generics if the parse fails for any reason.
I think there's another possibility of using
rewrite_events
the way that theJsParser
does to avoid the need for rewinding, but I think it's actually okay to just rewind since there's little cost to it, and we aren't enforcing a particular structure on the re-parsed content (it could be eitherGenericComponentValueList
orBogus
, we don't actually know at the point of rewinding).Test Plan
Added a test around
try_parse
to ensure it rewinds as expected on error and preserves the position on success. Future PRs will start actually using it in the parser logic itself.